﻿using System;
using System.Collections;
using System.Linq;
using System.Text;

namespace Galoap
{
    partial class ColorTagQuestion : Question
    {
        /*
         * @ THIS IS A OLD PROTOTYPE OF THE GAME
         * 

        /// <summary>
        /// exadecimal representing the color
        /// </summary>
        public StringAnswer QuestionColor
        {
            get
            {
                try
                {
                    Answer.Load();
                    return GetMostFrequentAnswer<StringAnswer>().First();
                }
                catch (InvalidOperationException)
                {
                    return null;
                }
            }
            set { QuestionColor = value; }
        }

        /// <summary>
        /// The constructor of the ImageTagQuestion
        /// </summary>
        // public ColorTagQuestion(Category c) : base()
        // {
        //     Text = new ConfirmColorQuestionText();
        // }

        /// <summary>
        /// The constructor of the ImageTagQuestion
        /// </summary>
        public ColorTagQuestion()
            : base()
        {
            if (QuestionColor != null)
                Text = new QuestionText();
        }

        public override void Initialize()
        {
            if (QuestionColor != null)
                Text = new QuestionText();
        }

        public override bool Validate(string reply)
        {
            reply = reply.ToLower();
            if ((reply.Equals("si") || reply.Equals("no")) && QuestionColor != null)
                return true;
            else
                return MyColors.ExistsColorName(reply);
        }

        public override string ToJSON()
        {
            StringBuilder sb = new StringBuilder("\"help\":\"\",");
            sb.Append("\"knowledge\":[");
            sb.Append("\"" + QuestionColor + "\"");
            sb.Append("]");
            return "{" + base.ToJSON() + ExtendJSON(sb.ToString()) + "}";
        }
        */
    }
}
